package com.pure.service.impl;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Service;

import com.pure.dao.UserMapper;
import com.pure.db.User;
import com.pure.db.UserExample;
import com.pure.service.UserService;

@Service
public class UserServiceImpl extends CommonServiceImpl implements UserService {

	@Resource
	private UserMapper tUsersMapper;

	@Override
	public User login(String username, String password, Integer type) {
		// TODO Auto-generated method stub
		UserExample example = new UserExample();
		example.createCriteria().andUsernameEqualTo(username).andPasswordEqualTo(password).andTypeEqualTo(type);
		User user = tUsersMapper.selectByExample(example).get(0);
		return user;
	}

	@Override
	public Integer register(User user) {
		return tUsersMapper.insertSelective(user);
	}

	@Override
	public Integer updateUser(User user) {
		// TODO Auto-generated method stub
		return tUsersMapper.updateByPrimaryKeySelective(user);
	}

	@Override
	public User getUserById(Integer id) {
		// TODO Auto-generated method stub
		return tUsersMapper.selectByPrimaryKey(id);
	}

}
